﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DungChung;
namespace CoVuaServer
{
    class LoaiKetQuaDAO : DAO
    {
        public LoaiKetQuaDAO(DataProvider dataProvider)
        {
            _dataProvider = dataProvider;
        }
        protected override object GetDataFromRow(DataTable dataTable, int index)
        {
            LoaiKetQuaDTO loaiKetQua = new LoaiKetQuaDTO();
            loaiKetQua.MaLoai = Convert.ToInt32(dataTable.Rows[index]["MaLoai"]);
            loaiKetQua.TenLoai = dataTable.Rows[index]["TenLoai"].ToString();
            loaiKetQua.CauMoTa = dataTable.Rows[index]["CauMoTa"].ToString();
            loaiKetQua.Diem = Convert.ToInt32(dataTable.Rows[index]["Diem"]);
            return (object)loaiKetQua;
        }
        public List<LoaiKetQuaDTO> GetAllLoaiKetQua(string query)
        {
            List<LoaiKetQuaDTO> loaiKetQuas = new List<LoaiKetQuaDTO>();
            DataTable dataTable = _dataProvider.Execute(query);
            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                loaiKetQuas.Add((LoaiKetQuaDTO)GetDataFromRow(dataTable, i));
            }
            return loaiKetQuas;
        }
    }
}
